﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NewBee.Core.BusinessService;
using NewBee.Core.Models;
using NewBee.Core.Data.Model;
using System.Collections;

namespace WebMvc.ApiControllers
{
    [Route("api/[controller]")]
    public class ValuesController : Controller
    {
        // GET api/values

        [HttpGet]
        public IEnumerable<AdminLoginLog> Get()
        {
            AgentFactory _AgentFactory = new AgentFactory();

            IEnumerable<AdminLoginLog> list = _AgentFactory.AdminLoginLog.Get();

            //Hashtable ht = new Hashtable();
            //ht.Add("ID", 1);
            //ht.Add("NAME", "AAA");
            //ht.Add("SEX", "MAIL");
            //ht.Add("AGE", 25);
            //string a = ht.Keys.ToString();
            //string b = ht.Values.ToString();
            //NewBee.Core.Data.DbHelper db = new NewBee.Core.Data.DbHelper(string.Empty, string.Empty, string.Empty);
            //NewBee.Core.Data.SQLBuilder.Insert ins = new NewBee.Core.Data.SQLBuilder.Insert(db, "aa");
            //ins.Column(ht);
            //ins.Execute();
            return list;
        }

        [HttpGet("Search/{page}")]
        public PageResult Get(int page, string where)
        {
            AgentFactory _AgentFactory = new AgentFactory();

            PageResult list = _AgentFactory.AdminLoginLog.Search(page, where);

            return list;
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public AdminLoginLog Get(long id)
        {
            AgentFactory _AgentFactory = new AgentFactory();

            AdminLoginLog list = _AgentFactory.AdminLoginLog.Get(id);
            
            return list;
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(long id)
        {
            AgentFactory _AgentFactory = new AgentFactory();

            _AgentFactory.AdminLoginLog.Delete(id);
        }
    }
}
